#include <myheader_c_plus.h>
#include "line.h"

using std::cout;
using std::endl;

//begin of the LineImpl
class Line::LineImpl{
public:
    LineImpl(int x1, int y1, int x2, int y2)
    :pt1(x1, y1)
    ,pt2(x2, y2)
    {

    }


    
    void print(){
        pt1.print();
        cout << "---->";
        pt2.print();
        cout << endl;
    }
private:
    //begin of the Point 
    class Point {
    public:
        Point(int x, int y)
        :_x(x)
        ,_y(y)
        {

        }

        void print(){
            cout << "(" << _x << "," << _y << ")";
        }

    private:
        int _x;
        int _y;

    };
    //end of the Point
    Point pt1;
    Point pt2;

};
//end of the LineImpl


Line::Line(int x1, int y1, int x2, int y2)
:_impl(new LineImpl(x1, y1, x2, y2))
{
    
}

Line::~Line(){
    if(_impl != nullptr){
        delete _impl;
        _impl = nullptr;
    }
}

void Line::printLine(){
    _impl ->print();

}
int main(int argc, char *argv[])
{
    Line line(1,2,3,4);

    line.printLine();
    return 0;
}

